/*
ID: huangmingbo
LANG: JAVA
TASK: ride
*/
import java.io.*;
import java.util.StringTokenizer;

/**
 * read two line upper string, max count is 6
 * ABCDEF
 * EE
 * each character convert to number (A-Z->1-26) and mod 47, i.e.
 * 1*2*3*4*5*6 mod 47 = 15
 * 5*5 mod 47 = 25
 *
 * when the mod result is equal, print GO otherwise print STAY
 */
class ride {



    public static void main(String[] args) throws IOException {

        InputStream inputStream = ride.class.getResourceAsStream("ride.in");
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream,"UTF-8");
        BufferedReader fileInput = new BufferedReader(inputStreamReader);

        // ride.out
        PrintWriter printWriter = new PrintWriter(new FileWriter("ride.out"));

        // read first line
        String s1 = fileInput.readLine();
        // second line
        String s2 = fileInput.readLine();

        int mod1 = getMod(s1);
        int mod2 = getMod(s2);
        // print
        if (mod1 == mod2) {
            printWriter.println("GO");
        } else {
            printWriter.println("STAY");
        }
        printWriter.close();

    }

    private static int getMod(String s1) {
        int ret = 1;
        for(int i = 0; i < s1.length(); i++){
            ret *= s1.charAt(i) - 'A' + 1;
        }
        return ret % 47;
    }
}
